﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using Beyond;

public class ContinueDialog : YesNoDialog
{
    public static ContinueDialog Instance;

    public Text message;
    public Button freeRuby;
    public GameObject enoughRuby, notEnoughRuby;
    bool videoReady;
    int current;

    protected override void Awake()
    {
        base.Awake();
        Instance = this;
        current = CurrencyController.GetBalance();
    }

    protected override void Start()
    {
        base.Start();
        //StartCoroutine(IECountDown(7));
        freeRuby.onClick.AddListener(delegate {
            freeRuby.gameObject.SetActive(false);
            AdsProxy.PlayVideoByType(AdsProxy.VideoType.VideoToResurgence);
        });

        //int totalCount = ConfigController.Config.rubyCostToContinue.Length;
        //int cost = ConfigController.Config.rubyCostToContinue[MainController.instance.continueCount];
        //if (CurrencyController.GetBalance() >= cost && MainController.instance.continueCount < totalCount)
        //{
        //    enoughRuby.SetActive(true);
        //}
        //else
        //{
        //    notEnoughRuby.SetActive(true);
        //}
        //if (GameState.isFristChallenge && Ads.isReady(Ads.Type.video))
        //{
        //    freeRuby.gameObject.SetActive(true);
        //}
    }

    void Update()
    {

    }

    public IEnumerator IECountDown(int time)
    {
        while (time > 0)
        {
            yield return new WaitForSeconds(1);
            time--;
        }
        OnNoClick();
        GameState.isFristChallenge = false;
    }
}
